<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>实验环境实例监控</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }

		function viewResourceDetail(id){
			console.info(id);
			$.ajax({
				type: "POST",
				url: "${ctx}/scene/sceneVmTemplate/viewResourceDetail",
				data: {
					ids:id
				},
				<%--data: {id:${"#id"}.val()},--%>
				success: function (sceneVmTemplate) {

					$("#resourceTable").append("<li>" + 'VCPU数量: '+sceneVmTemplate.vcpus+"</li>");
					$("#resourceTable").append("<li>" + '内存大小(MB): '+sceneVmTemplate.ram+"</li>");
					$("#resourceTable").append("<li>" + '存储空间(GB): '+sceneVmTemplate.disk+"</li>");



				},
				error:function(){
					alert("error");
				}
			});
			$.jBox($("#viewResourceDetailBox").html(), {title:"资源占用详情", buttons:{"关闭":true}, submit: function(){}});

		}
	</script>
	<script type="text/template" id="viewResourceDetailBox">
		<div>
			<ul id="resourceTable">
			</ul>
		</div>
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/scene/sceneVmTemplate/instanceMonitor">实验环境实例监控</a></li>
		<li><a href="${ctx}/scene/sceneVmTemplate/ctfInstanceMonitor">CTF实验环境实例监控</a></li>

	</ul>
	<form:form id="searchForm"  action="${ctx}/scene/sceneVmTemplate/instanceMonitor" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
			<li><label>创建时间：</label>
				<input name="beginEndDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
					   value="<fmt:formatDate value="${actEvtLog.beginTimeStamp}" pattern="yyyy-MM-dd HH:mm:ss"/>"
					   onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/> -
				<input name="endEndDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
					   value="<fmt:formatDate value="${actEvtLog.endTimeStamp}" pattern="yyyy-MM-dd HH:mm:ss"/>"
					   onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
			</li>
			<li><label>创建用户：</label>
				<input type="text" id="createBy.id" name="createBy" maxlength="64" class="input-medium" value="${createBy}"/>
			</li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>虚拟机名称</th>
				<th>实验名称</th>
				<th>虚拟机模板</th>
				<th>创建时间</th>
				<th>创建用户</th>
				<th>资源占用</th>
				<th>操作</th>

			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="sceneEnvironmentInstance">
			<tr>
				<td>
					${sceneEnvironmentInstance.vmName}
				</td>
				<td>
					${sceneEnvironmentInstance.environmentName}
				</td>
				<td>
					${sceneEnvironmentInstance.vmTemplateName}
				</td>
				<td>
					<fmt:formatDate value="${sceneEnvironmentInstance.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<td>
						${sceneEnvironmentInstance.createBy}
				</td>
				<td>
				<a href="javascript:viewResourceDetail('${sceneEnvironmentInstance.vmId}')" title="查看">查看</a></td>
				</td>
				<td>
					<a href="${ctx}/scene/sceneVmTemplate/deleteInstance?instanceId=${sceneEnvironmentInstance.id}&vmTemplateId=${sceneEnvironmentInstance.vmTemplateId}&type=0" onclick="return confirmx('确认要销毁该实例吗？', this.href)">销毁</a>
					<a href="${ctx}/scene/sceneVmTemplate/rebootServer?id=${sceneEnvironmentInstance.vmTemplateId}&type=0" onclick="return confirmx('确认要重启吗？', this.href)">重启</a>
				</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>